#pragma once
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>

namespace krryn{
namespace core{
	std::vector<std::string> explode(const std::string &a_Input, const std::string &a_Delimiter){
		typedef std::string::size_type size_type;

		std::vector<std::string> l_Result;

		for(size_type i = 0, j = 0;  ; i = j + a_Delimiter.length()){
			j = a_Input.find(a_Delimiter, i);
			if(j != std::string::npos){
				l_Result.push_back(a_Input.substr(i, j - i));
			}else{
				break;
			}
		}

		return l_Result;
	}

	std::string implode(const std::vector<std::string> &a_Input, const std::string &a_Delimiter){
		std::stringstream l_Stream;
		std::copy(a_Input.begin(), a_Input.end() - 1, std::ostream_iterator<std::string>(l_Stream, a_Delimiter.c_str()));

		l_Stream << a_Input.back() << std::endl;

		return l_Stream.str();
	}
}
}